using System;
using System.Text;
using Microsoft.SharePoint;

namespace WordToSharePoint
{
  public class FeatureReceiver : SPFeatureReceiver {

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPFeature feature = (SPFeature)properties.Feature;
        SPWeb site = (SPWeb)properties.Feature.Parent;

        foreach (SPWeb childWeb in site.Webs)
        {
            try
            {
                childWeb.Features.Add(feature.DefinitionId, true);
            }
            catch(Exception ex)
            {
                // handle exception via logging
            }
        }
    }

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties) 
    {
        SPFeature feature = (SPFeature)properties.Feature;
        SPWeb site = (SPWeb)properties.Feature.Parent;

        foreach (SPWeb childWeb in site.Webs)
        {
            try
            {
                childWeb.Features.Remove(feature.DefinitionId, true);
            }
            catch (Exception ex)
            {
                // handle exception via logging
            }
        }      
    }

    public override void FeatureInstalled(SPFeatureReceiverProperties properties) { 
      // no operation implemented
    }

    public override void FeatureUninstalling(SPFeatureReceiverProperties properties) {
        // no operation implemented
    }
  }
}
